package com.htudata.core.util.operation;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExpOperationUtils {

  public static final String ZH = "[\\u4e00-\\u9fa5]";
  
  public static final String DATE = "(y|M|d|H|m|s|:|[\\u4e00-\\u9fa5]|\\s)*";
  
  public static final String DATE2 = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)  [0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [0-9]{4}";
  
  public static final String POSITIVE_INT = "[1-9]\\d*";
  
  public static final String UINT = "[1-9]\\d*|0";
  
  public static final String UINT_AND_NEGATIVE_INT = "-?[1-9]\\d*|0";
  
  public static final String NUMERIC = "((-?[1-9]\\d*\\.?\\d*(?<!\\.)$)|(-?0\\.\\d*(?<!\\.)$)|0)";
  
  public static boolean matches(String src, String regex) {
    if (!StringOperationUtils.isValidStr(src))
      return false; 
    if (!StringOperationUtils.isValidStr(regex))
      return false; 
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(src);
    boolean result = matcher.matches();
    return result;
  }
}
